package edu.ec.java02.group02.controller;

import edu.ec.java02.group02.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/front")
public class FrontController {

    @Autowired
    private ProductService productService;

    @RequestMapping("login")
    public String login(){
        return "front/login";
    }

    @RequestMapping("home")
    public String home(HttpServletRequest request){
        request.setAttribute("cake",productService.getProductByType("蛋糕"));
        request.setAttribute("cooky",productService.getProductByType("饼干"));
        request.setAttribute("meat",productService.getProductByType("肉类"));
        request.setAttribute("vege",productService.getProductByType("素食"));
        request.setAttribute("nut",productService.getProductByType("坚果"));
        request.setAttribute("sugar",productService.getProductByType("糖果"));
        request.setAttribute("choco",productService.getProductByType("巧克力"));
        request.setAttribute("jelly",productService.getProductByType("果冻"));
        request.setAttribute("noodles",productService.getProductByType("泡面"));
        request.setAttribute("drink",productService.getProductByType("饮料"));

        return "front/home";
    }

}
